﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Autofac;
using Dapper_Core.BLL.Impl;
using Dapper_Core.BLL.Interface;
using Microsoft.AspNetCore.Mvc;

namespace Dapper_Core.Web.Controllers
{
    public class ServiceExposeInterfaceResolveAllController : Controller
    {
        private IPlayService playService;
        private IPayService payService;
        private IComponentContext componentContext;
        public ServiceExposeInterfaceResolveAllController(IPlayService playService, IPayService payService, IComponentContext componentContext)
        {
            this.playService = playService;
            this.payService = payService;
            this.componentContext = componentContext;
        }

        public IActionResult Index()
        {
            ViewData["play"] = playService.Play();
            ViewData["pay"] = payService.Pay();
            ViewData["wxpay"] = componentContext.ResolveNamed<IPayService>(typeof(WxpayService).Name).Pay();
            ViewData["alipay"] = componentContext.ResolveNamed<IPayService>(typeof(AlipayService).Name).Pay();
            ViewData["resolveIPayService"] = componentContext.Resolve<IPayService>().Pay();
            ViewData["typeof(WxpayService).Name"] = typeof(WxpayService).Name;
            return View();
        }
    }
}